package com.feihong.yw189.bluetooth.startreadcard;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.RequiresApi;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.util.Log;

import com.feihong.yw189.app.App;
import com.feihong.yw189.bluetooth.bean.GetIpInfo;
import com.feihong.yw189.bluetooth.bleutils.BleGlobUtils;
import com.feihong.yw189.bluetooth.bleutils.BleHttpUtils;
import com.feihong.yw189.bluetooth.listener.UpLoadListener;
import com.feihong.yw189.bluetooth.server.BLEService;
import com.feihong.yw189.bluetooth.server.NFCReaderService;
import com.feihong.yw189.bluetooth.server.USBHIDService;
import com.feihong.yw189.bluetooth.utils.djlm.DJLMReader3.reader.CardInfo;
import com.feihong.yw189.bluetooth.utils.djlm.DJLMReader3.reader.DJLM3CallBack;
import com.feihong.yw189.bluetooth.utils.djlm.DJLMReader3.reader.NewDJLMReader2;
import com.feihong.yw189.bluetooth.utils.djlm.newDJMLReader.DJLM_CardReader;
import com.feihong.yw189.bluetooth.utils.djlm.newDJMLReader.DJLM_ReaderCallBack;
import com.feihong.yw189.bluetooth.utils.util.CardDeviceIO;
import com.feihong.yw189.bluetooth.utils.util.IDCardReadCtrl;
import com.feihong.yw189.listener.http.RequestCallBack;
import com.google.gson.Gson;
import com.kaeridcard.client.BtReaderClient;

import org.xutils.common.Callback;

import java.util.Date;

import static com.feihong.yw189.app.App.showToast;


/**
 * 店家联盟读卡
 * 2017/8/24
 * 张鹏
 */
public class DjlmConnectUtils {
    private BluetoothDevice remoteDevice;
    private String bleAddress;
    private BluetoothAdapter ba;
    private Context context;
    private Activity mActivity;

    private String name, sex, nation, id_num, address, sign_office, to, from, born;
    private String birth_year, birth_month, birth_day, sign_data, photoHeard;
    private Bitmap photo;
    private String bluetoothName = "";
    private BleHttpUtils bleHttpUtils;
    private Boolean mFlag = false;
    // 注册成功失败监听
    private UpLoadListener mOnUpLoadListener;

    private LocalBroadcastManager instanceDjlm;
    private USBHIDService mUSBHIDService = null;
    private CardDeviceIO mCardDeviceIO = null;
    private NewDJLMReader2 newDJLMReader2;
    private String bleName;

    public static final String NFC_NO_OPEN_CODE = "1";
    /**
     * 需要在Application里面初始化 BluetoothContext.set(this);//初始化蓝牙
     *
     * @param context
     * @param ba
     * @param remoteDevice
     * @param bleAddress
     * @param bluetoothName
     * @param flag
     * @param mOnUpLoadListener
     */
    public DjlmConnectUtils(Context context, BluetoothAdapter ba, BluetoothDevice remoteDevice,
                            String bleName,String bleAddress, final String bluetoothName,
                            Boolean flag, final UpLoadListener mOnUpLoadListener) {
        this.context = context;
        this.mActivity = (Activity) context;
        this.ba = ba;
        this.remoteDevice = remoteDevice;
        this.bleName = bleName;
        this.bleAddress = bleAddress;
        this.mFlag = flag;
        this.bluetoothName = bluetoothName;
        this.mOnUpLoadListener = mOnUpLoadListener;
    }

    private BtReaderClient mClient;

    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
    public void connect(BtReaderClient mClient, Boolean isNfc) {
        this.mClient = mClient;

        bleHttpUtils = new BleHttpUtils(context, bluetoothName, mFlag, new UpLoadListener() {
            @Override
            public void onSucUpLoad(String bluetoohName, String address, String sex, String id_num,
                                    String nation, String sign_office, String name, String sign_data,
                                    String birth_year, String birth_month, String birth_day,
                                    Bitmap photo, String filePhoto, String idPath, String to,
                                    String from, String born, String photoHeard) {

                mOnUpLoadListener.onSucUpLoad(bluetoothName, address, sex, id_num, nation,
                        sign_office, name, sign_data, birth_year, birth_month, birth_day,
                        photo, filePhoto, idPath, to,
                        from, born, photoHeard);
                // 读卡成功需要断开连接
                stopConnect();
            }

            @Override
            public void onErrUpLoad(String err) {
                mOnUpLoadListener.onErrUpLoad(err);
                // 读卡失败需要断开连接
                stopConnect();
            }

        });
        if (isNfc) {
            if (NFC_Init()) {
                getIpNet(true);
            }

        } else {
            if (remoteDevice != null && remoteDevice.getName() != null
                    && !remoteDevice.getName().toUpperCase().startsWith("DJLM1")) {
                if (ba != null && ba.isDiscovering()) {
                    ba.cancelDiscovery();
                }
                djlm_MacAddress = bleAddress;
                getIpNet(false);
            } else {
                if (!BLE_init()) {
                    mOnUpLoadListener.onErrUpLoad("蓝牙初始化失败");
                } else {
                    instanceDjlm = LocalBroadcastManager.getInstance(context);
                    instanceDjlm.registerReceiver(UARTStatusChangeReceiver, makeGattUpdateIntentFilter());
                    mUSBHIDService = USBHIDService.GetUSBHIDService(mActivity.getApplication());
                    mCardDeviceIO = CardDeviceIO.GetCardDeviceIO();
                    BLEReadOnce(bleAddress);
                }
            }
        }
    }

    /**
     * 断开连接
     */
    public void stopConnect() {
        try {
            // 断开读卡器连接
            if (mClient != null) {
                mClient.disconnectBt();
            }
            if (mBLETrans != null) {
                mBLETrans.disconnect();
            }
            if (mCardDeviceIO != null) {
                mCardDeviceIO.UninitDevice(true);
            }
            if (djlm_cardReader != null) {
                djlm_cardReader.disconnect();
            }
            Log.e("项目异常djlm", "------djlm断开连接------");
        } catch (Exception e) {
            Log.e("项目异常", "------断开连接异常------" + e.toString());
            mOnUpLoadListener.onErrUpLoad("");
            e.printStackTrace();
        }

    }

    private BLEService mBLETrans = null;
    private static final int UART_PROFILE_DISCONNECTED = 21;
    private int mState = UART_PROFILE_DISCONNECTED;
    private static final int UART_PROFILE_CONNECTED = 20;

    /**
     * 店家联盟
     * 刷新蓝牙连接状态
     */
    private void RefreshConnectState() {

        if (mBLETrans.mConnectionState == BLEService.STATE_CONNECTED) {
            mState = UART_PROFILE_CONNECTED;

        } else {
            mState = UART_PROFILE_DISCONNECTED;
        }
    }

    boolean m_bDisconnect = false;
    private IDCardReadCtrl mIDCardReaderCtrl = null;
    /**
     * 店家联盟
     * 正在读取身份证信息
     */
    DJLM_CardReader djlm_cardReader = null;

    void ReadIDCardAllInOne(final String strAllocApp, int nDeviceType, boolean bDisconnect) {

        if (nDeviceType == CardDeviceIO.DEVICETYPE_BLE) {
            try {
                djlm_cardReader = new DJLM_CardReader(context, strAllocApp, djlm_MacAddress, new DJLM_ReaderCallBack() {
                    @Override
                    public void readData(String strResultInfo) {

                        final String nr = strResultInfo;
                        Identityinformation = nr.replaceAll(" ", "");
                        if (Identityinformation.contains("no Find Card!")) {
                            mOnUpLoadListener.onErrUpLoad("请确认身份证正确放置");
                            Identityinformation = null;
                        } else if (!Identityinformation.contains("姓名")) {
                            Identityinformation = null;
                            mOnUpLoadListener.onErrUpLoad("读取失败:" + nr);
                        }
                    }

                    @Override
                    public void readDataError(String error) {
                        mOnUpLoadListener.onErrUpLoad(error);
                    }

                    @Override
                    public void parseBitmapSuccess(Bitmap picBitmap) {
                        DjlmPhoto = picBitmap;
                        if (Identityinformation != null && Identityinformation.contains("姓名") && DjlmPhoto != null) {
                            djlmBlueToolsRead(Identityinformation, DjlmPhoto);
                        } else {
                            mOnUpLoadListener.onErrUpLoad("获取身份证信息或头像失败");
                        }
                    }

                    @Override
                    public void parseBitmapError(String error) {
                        mOnUpLoadListener.onErrUpLoad(error);
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                mOnUpLoadListener.onErrUpLoad("读取异常:" + e.toString());
            }
        } else {
            m_bDisconnect = bDisconnect;
            if (mIDCardReaderCtrl == null) {

                if (mIDCardReaderCtrl == null)
                    mIDCardReaderCtrl = new IDCardReadCtrl();
                if (mCardDeviceIO.InitDevice(mBLETrans, mUSBHIDService, mNFCReaderService, nDeviceType)) {
                    if (nDeviceType == 1) {
                        mActivity.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                showToast("正在读卡，请勿移动!");
                            }
                        });
                    }

                    mIDCardReaderCtrl.StartRead(context,
                            mCardDeviceIO, strAllocApp, 30000, new Handler() {
                                @Override
                                public void handleMessage(Message msg) {
                                    switch (msg.what) {
                                        case 0: {
                                            DjlmPhoto = (Bitmap) msg.obj;
                                            if (Identityinformation.contains("姓名") && DjlmPhoto != null) {
                                                djlmBlueToolsRead(Identityinformation, DjlmPhoto);
                                            } else {
                                                mOnUpLoadListener.onErrUpLoad("获取身份证信息或头像失败");
                                            }
                                        }
                                        break;
                                        case 1: {
                                            final String nr = msg.obj.toString();
                                            Identityinformation = nr.replaceAll(" ", "");
                                            if (Identityinformation.contains("no Find Card!")) {
                                                mOnUpLoadListener.onErrUpLoad("请确认身份证正确放置");
                                            } else if (!Identityinformation.contains("姓名")) {
                                                mOnUpLoadListener.onErrUpLoad("读取失败:" + nr);
                                            }
                                        }
                                        break;
                                    }

                                    mCardDeviceIO.UninitDevice(m_bDisconnect);
                                    mIDCardReaderCtrl = null;
                                }
                            });
                }

            } else {
                mOnUpLoadListener.onErrUpLoad("初始化设备失败,mIDCardReaderCtrl为空");
                mCardDeviceIO.UninitDevice(bDisconnect);
                mIDCardReaderCtrl = null;
            }
        }
    }


    private Bitmap DjlmPhoto;
    private String Identityinformation;

    private boolean BLE_init() {
//        if (BluetoothAdapter.getDefaultAdapter() == null) {
//            mOnUpLoadListener.onErrUpLoad("该蓝牙设备不可用");
//            return false;
//        }
        mBLETrans = BLEService.GetBLEService(context);
        if (!mBLETrans.initialize()) {
            return false;
        }
        return true;
    }

    private String djlm_MacAddress = "";

    private void BLEReadOnce(String strAddress) {
        if (ba.isDiscovering()) {
            ba.cancelDiscovery();
        }
        djlm_MacAddress = strAddress;

        getIpNet(false);
    }

    //测试地址
    public static String m_strBmpURL = "http://220.171.49.36:8090/MutexComm/";
//    public static String m_strBmpURL = "http://124.88.117.108:8090/MutexComm/";

    private void getIpNet(final boolean bleFlag) {
        App.getApp().getHttpTools().getDJLMIP(new RequestCallBack() {
            @Override
            public void onSuccess(Object result) {
                try {
                    Gson gson = new Gson();
                    GetIpInfo djlmInfo = gson.fromJson(result.toString(), GetIpInfo.class);
                    if (djlmInfo != null) {
                        if (djlmInfo.getStatus() == 1) {
                            final String url = djlmInfo.getData().getUrl();
                            if (url != null && !TextUtils.isEmpty(url)) {
                                if (bleFlag) {
                                    bluetoothName = "NFC读卡";
                                    ReadIDCardAllInOne(url, CardDeviceIO.DEVICETYPE_NFC, false);
                                } else {
                                    if (remoteDevice != null && remoteDevice.getName() != null
                                            && !remoteDevice.getName().toUpperCase().startsWith("DJLM1")) {
                                        Log.e("项目异常", "------店家联盟新读卡------");
                                        // 店家联盟新读卡
                                        String ip = djlmInfo.getData().getIp(); // 8090

                                        String url_new = djlmInfo.getData().getUrl_new(); // 8093
//                                        String host = url;
//                                        host = host.substring("http://".length());
//                                        host = host.substring(0, host.indexOf(":"));
                                        newDJLMReader2 = new NewDJLMReader2(mActivity, ip, url_new, callBack);
                                        newDJLMReader2.setHost(ip, url_new);
                                        newDJLMReader2.read(djlm_MacAddress);//开始读卡
                                    } else {
                                        // 店家联盟旧读卡
                                        Log.e("项目异常", "------店家联盟旧读卡------" + url);
                                        ReadIDCardAllInOne(url, CardDeviceIO.DEVICETYPE_BLE, true);
                                    }
                                }
                            } else {
                                mOnUpLoadListener.onErrUpLoad("服务器返回IP地址为空");
                            }
                        } else {
                            mOnUpLoadListener.onErrUpLoad(djlmInfo.getInfo());
                        }
                    } else {
                        mOnUpLoadListener.onErrUpLoad("服务器返回数据为空");
                    }
                } catch (Exception e) {
                    Log.e("项目异常", "------店家联盟新读卡数据解析异常------" + e.toString());
                    mOnUpLoadListener.onErrUpLoad("数据解析异常");
                }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                mOnUpLoadListener.onErrUpLoad("网络或服务器错误");
            }

            @Override
            public void onCancelled(Callback.CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }

    /***
     * 店家联盟新板子 DJLM3开头的 读卡结果回调
     */
    public DJLM3CallBack callBack = new DJLM3CallBack() {
        @Override
        public void success(CardInfo cardInfo) {
            String strInfo;
            Identityinformation = "姓名:" + cardInfo.str_name
                    + "性别:" + cardInfo.str_sex
                    + "民族:" + cardInfo.str_Nation
                    + "出生:" + cardInfo.str_Birth
                    + "住址:" + cardInfo.str_Address
                    + "公民身份号码:" + cardInfo.str_IDCode
                    + "签发机关:" + cardInfo.str_Regorg
                    + "有效期限:" + cardInfo.str_startDate
                    + "-" + cardInfo.str_endDate;
            Identityinformation = Identityinformation.replace(" ", "");
            DjlmPhoto = cardInfo.bitmap_pic.copy(cardInfo.bitmap_pic.getConfig(), true);
            try {
                cardInfo.bitmap_pic.recycle();
                cardInfo = null;
                newDJLMReader2 = null;
            } catch (Exception ex) {
                mOnUpLoadListener.onErrUpLoad("读卡异常:" + ex.toString());
            }
            djlmBlueToolsRead(Identityinformation, DjlmPhoto);


        }

        @Override
        public void error(int code, final String msg) {
            mActivity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Log.e("项目异常", "------onSucUpLoad--error----" + msg);
                    mOnUpLoadListener.onErrUpLoad("读卡失败:" + msg);

                }
            });
        }
    };
    /**
     * 截取两字符之间的字符串，str 和 start不能为null或""
     */
    public static String getCutOutString(String str, String start, String endwith) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        String result = "";
        if (str.contains(start)) {
            String s1 = str.split(start)[1];
            if (endwith == null || "".equals(endwith)) {
                result = s1;
            } else {
                String s2[] = s1.split(endwith);
                if (s2 != null) {
                    result = s2[0];
                }
            }
        }
        return result;

    }
    /**
     * 店家联盟  读取蓝牙结果显示
     */
    private void djlmBlueToolsRead(String Identityinformation, Bitmap DjlmPhoto) {
        String t_name = null;
        String t_sex = null;
        String t_nation = null;
        String t_born = null;
        String t_address = null;
        String t_id_num = null;
        String t_sign_office = null;
        String t_sign_data = null;
        String soure = Identityinformation;

        t_name = getCutOutString(soure, "姓名:", "性别:");
        Log.e("项目异常", "------Identityinformation1------" + t_name);

        t_sex = getCutOutString(soure, "性别:", "民族:");
        Log.e("项目异常", "------Identityinformation1------" + t_sex);

        t_nation = getCutOutString(soure, "民族:", "出生:");
        Log.e("项目异常", "------Identityinformation1------" + t_nation);

        t_born = getCutOutString(soure, "出生:", "住址:");
        Log.e("项目异常", "------Identityinformation1------" + t_born);

        t_address = getCutOutString(soure, "住址:", "公民身份号码:");
        Log.e("项目异常", "------Identityinformation1------" + t_address);

        t_id_num = getCutOutString(soure, "公民身份号码:", "签发机关:");
        Log.e("项目异常", "------Identityinformation1------" + t_id_num);

        t_sign_office = getCutOutString(soure, "签发机关:", "有效期限:");
        Log.e("项目异常", "------Identityinformation1------" + t_sign_office);

        t_sign_data = getCutOutString(soure, "有效期限:", "");
        Log.e("项目异常", "------Identityinformation1------" + t_sign_data);

        photo = DjlmPhoto;
        photoHeard = BleGlobUtils.replaceBlank(
                BleGlobUtils.bitmapToBase64(photo));
        name = t_name;//姓名
        sex = t_sex;//性别
        nation = t_nation;//民族
        born = t_born.substring(0, 4) + "-" + t_born.substring(5, 7)
                + "-" + t_born.substring(8, 10);
        birth_year = t_born.substring(0, 4);
        birth_month = t_born.substring(5, 7);
        birth_day = t_born.substring(8, 10);

        address = t_address;//地址
        id_num = t_id_num;  //身份证号
        sign_office = t_sign_office;  //签发机关

        from = t_sign_data.substring(0, 4) + "-" +
                t_sign_data.substring(5, 7) + "-" +
                t_sign_data.substring(8, 10);
        if (t_sign_data.contains("长期")) {
            sign_data = t_sign_data.substring(0, 4)
                    + "." + t_sign_data.substring(5, 7) + "." +
                    t_sign_data.substring(8, 10) + "--" +
                    "长期";
            to = "长期";
        } else {
            to = t_sign_data.substring(12, 16) + "-" +
                    t_sign_data.substring(17, 19) + "-" +
                    t_sign_data.substring(20, 22);
            sign_data = t_sign_data.substring(0, 4)
                    + "." + t_sign_data.substring(5, 7) + "." +
                    t_sign_data.substring(8, 10) + "--" +
                    t_sign_data.substring(12, 16) + "."
                    + t_sign_data.substring(17, 19) + "." +
                    t_sign_data.substring(20, 22);
        }
        Log.e("项目异常", name + "------onSucUpLoad身份证信息------" + id_num);
        bleHttpUtils.upLoadSfzPhoto( bleName, bleAddress,address, photoHeard, sex, id_num, nation,
                sign_office, to, name, from, born, sign_data, birth_year,
                birth_month, birth_day, photo);
    }

    private NFCReaderService mNFCReaderService = null;

    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
    private boolean NFC_Init() {
        // djlm  NFC初始化及调用
        instanceDjlm = LocalBroadcastManager.getInstance(context);
        instanceDjlm.registerReceiver(UARTStatusChangeReceiver, makeGattUpdateIntentFilter());
        mUSBHIDService = USBHIDService.GetUSBHIDService(context);
        mUSBHIDService = USBHIDService.GetUSBHIDService(context);
        mCardDeviceIO = CardDeviceIO.GetCardDeviceIO();
        mNFCReaderService = NFCReaderService.GetNFCReaderService();
        mBLETrans = BLEService.GetBLEService(context);
        NfcAdapter nfcadapter = NfcAdapter.getDefaultAdapter(context);
        if (nfcadapter == null) {
            mOnUpLoadListener.onErrUpLoad("该设备不支持NFC");
            return false;
        } else if (!nfcadapter.isEnabled()) {
            mOnUpLoadListener.onErrUpLoad(NFC_NO_OPEN_CODE);
            return false;
        } else {

            Bundle opts = new Bundle();
            opts.putInt(NfcAdapter.EXTRA_READER_PRESENCE_CHECK_DELAY, 500);
            int flags = NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK;
            flags |= NfcAdapter.FLAG_READER_NFC_A;
            flags |= NfcAdapter.FLAG_READER_NFC_B;
            flags |= NfcAdapter.FLAG_READER_NFC_BARCODE;
            flags |= NfcAdapter.FLAG_READER_NFC_F;
            flags |= NfcAdapter.FLAG_READER_NFC_V;
            nfcadapter.enableReaderMode(mActivity, new NfcAdapter.ReaderCallback() {
                @Override
                public void onTagDiscovered(Tag tag) {
                    if (mCardDeviceIO != null)
                        mNFCReaderService.ProcessTag(tag);
                }
            }, flags, opts);
        }
        return true;
    }

    /**
     * 店家联盟所需广播
     */
    private final BroadcastReceiver UARTStatusChangeReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            final Intent mIntent = intent;
            if (action.equals(BLEService.ACTION_GATT_CONNECTED)) {
                final String strValue = intent.getStringExtra(BLEService.EXTRA_DATA);
                mActivity.runOnUiThread(new Runnable() {
                    public void run() {
                        RefreshConnectState();
                    }
                });
            } else if (action.equals(BLEService.ACTION_GATT_DISCONNECTED)) {
                final String strValue = intent.getStringExtra(BLEService.EXTRA_DATA);
                mActivity.runOnUiThread(new Runnable() {
                    public void run() {
                        RefreshConnectState();
                    }
                });
            } else if (action.equals(BLEService.ACTION_GATT_SERVICES_DISCOVERED)) {
            } else if (action.equals(BLEService.ACTION_DATA_AVAILABLE)) {
                final byte[] txValue = intent.getByteArrayExtra(BLEService.EXTRA_DATA);
                mActivity.runOnUiThread(new Runnable() {
                    public void run() {
                        try {
                            String text = new String(txValue, "UTF-8");
                            String currentDateTimeString = java.text.DateFormat.getTimeInstance()
                                    .format(new Date());
                        } catch (Exception e) {

                        }
                    }
                });
            } else if (action.equals(BLEService.ACTION_DATA_SEND)) {
                final byte[] rxValue = intent.getByteArrayExtra(BLEService.EXTRA_DATA2);
                mActivity.runOnUiThread(new Runnable() {
                    public void run() {
                        try {
                            String text = new String(rxValue, "UTF-8");
                            String currentDateTimeString = java.text.DateFormat.getTimeInstance()
                                    .format(new Date());
                        } catch (Exception e) {
                            Log.e("店家联盟广播", e.toString());
                        }
                    }
                });
            } else if (action.equals(BLEService.DEVICE_DOES_NOT_SUPPORT_UART)) {
            } else if (action.equals("IDCardReader")) {
                final String text = intent.getStringExtra("IDCardReader");
                mActivity.runOnUiThread(new Runnable() {
                    public void run() {
                        try {
                            String currentDateTimeString = java.text.DateFormat.getTimeInstance()
                                    .format(new Date());
                        } catch (Exception e) {
                            Log.e("店家联盟广播", e.toString());
                        }
                    }
                });
            }
        }
    };

    private static IntentFilter makeGattUpdateIntentFilter() {
        final IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(BLEService.ACTION_GATT_CONNECTED);
        intentFilter.addAction(BLEService.ACTION_GATT_DISCONNECTED);
        intentFilter.addAction(BLEService.ACTION_GATT_SERVICES_DISCOVERED);
        intentFilter.addAction(BLEService.ACTION_DATA_AVAILABLE);
        intentFilter.addAction(BLEService.ACTION_DATA_SEND);
        intentFilter.addAction("IDCardReader");
        intentFilter.addAction(BLEService.DEVICE_DOES_NOT_SUPPORT_UART);
        return intentFilter;
    }
}
